$(function ()
{
    findAll();
})

function findAll()
{
    let msg = {};
    msg.navName = $.trim($("#navName").val());
    msg.navHref = $.trim($("#navHref").val());
    msg.sort = $.trim($("#sort").val());
    msg.isShow = $.trim($("#isShow").val());
    msg.recommend = $.trim($("#recommend").val());
    msg.order = $.trim($("#order").val());
    msg.lift = $.trim($("#lift").val());
    msg.pageSize = $.trim($("#pageSize").val());
    msg.pageNum = $.trim($("#pageNum").val());
    msg.nowNum = $.trim($("#nowNum").val());

    let data = publivAjax('/back/nav/findAll', msg, 'get');

    let html = '';
    let list = data.list;
    $("#count").html(data.count);
    if (list != null)
    {
        for (let i = 0; i < list.length; i++)
        {
            html += '<tr>\n' +
                '                <td>' + list[i].id + '</td>\n' +
                '                <td>' + list[i].navName + '</td>\n' +
                '                <td>' + list[i].navHref + '</td>\n' +
                '                <td>' + list[i].sort + '</td>\n' +
                '                <td>' + (list[i].isShow == 1 ? '是' : '否') + '</td>\n' +
                '                <td>' + (list[i].recommend == 1 ? '是' : '否') + '</td>\n' +
                '                <td>' + list[i].createTime + '</td>\n' +
                '                <td>' + list[i].updateTime + '</td>\n' +
                '                <td>\n' +
                '                    <div><a href="javascript:edit(' + list[i].id + ')">编辑</a></div>\n' +
                '                    <div><a href="javascript:del(' + list[i].id + ')">删除</a></div>\n' +
                '                </td>\n' +
                '            </tr>';
        }
    }

    $("#findAll").html(html);
}

function edit(id)
{
    sessionStorage.setItem("navid", id);
    $('#b-right').load('/back/nav/navEdit.html')
}


function del(id)
{
    let data = publivAjax('/back/nav/del', {id: id}, 'post');

    if (data.result == 1)
    {
        findAll();
    }
}